$(function(){
    window.ci = layer.load();


    MyJson("http://datainfo.duapp.com/shopdata/getclass.php","get","","",successFn,errorFn);


        function successFn(data){
            layer.close(ci);
            var data = $.parseJSON(data);
            $(".nav-mine").empty();
            $(".nav-mine").append("<li class='active'><a href='index.html'>首页</a></li>");
            $.each(data,function(i,v){
                if(i<8){
                    var str = "<li><a href='product.html?classID="+ v.classID+"&classNme="+ v.className+"' >"+ v.className+"</a></li>";
                    $(".nav-mine").append(str);
                }
            });
            curActive()
        }

        function errorFn(data) {

        }

    function curActive(){
        var str = getData(window.location.search);
        str = decodeURI(str);
        var className = str.className
        if(className!="undefined"){
            $(".nav-mine li").removeClass("active");
            $(".nav-mine li a").each(function(i,v){
                if($(v).html()==className){
                    $(v).parent().addClass("active");
                }
            })
        }else{
            $(".nav-mine li a").first().addClass("active");
        }
    }
    window.curActive= curActive;


    function getData(str){
        var str = str.substring(1);
        str = str.split("&");
        var obj = {};
        $.each(str,function(i,v){
          var arr = v.split("=");
            console.log(arr);
            obj[arr[0]]= arr[1];
        });
        return obj;
    }
    window.getData = getData;


    if(window.location.search){
        var urlData = getData(window.location.search);
        var lbmc = decodeURI(urlData.className);
        var lbid = urlData.classID;
        var spmc = decodeURI(urlData.goodsName);
        var spid = urlData.goodsID;
        $("#location li").eq(1).html("<a href='product.html?classID="+lbid+"&className="+lbmc+"'>"+lbmc+"</a>")
        if(spid){
            $("#location li").eq(2).html(spmc);
        }else{
            $("#location li").eq(2).remove();
        }
    }

});